// Element Plus 组件样式覆盖
// 注意：此文件需要在 scoped 样式中引入，以便使用 :deep() 选择器

@import './utils.scss';

// el-switch 样式覆盖
:deep(.el-switch) {
  width: px2vw(60) !important;
  height: px2vw(31) !important;
  
  .el-switch__core {
    width: px2vw(60) !important;
    height: px2vw(31) !important;
    border-radius: px2vw(15.5) !important;
    background: transparent !important; // 默认未选中时透明
    border: px2vw(2) solid rgba(20, 109, 142, 1) !important;
    
    // 开关圆点
    .el-switch__action {
      width: px2vw(27) !important;
      height: px2vw(27) !important;
      background-color: #ffffff !important;
      box-shadow: 0 px2vw(2) px2vw(4) 0 rgba(0, 0, 0, 0.3);
    }
  }
  
  // 选中状态的样式
  &.is-checked {
    .el-switch__core {
      background: linear-gradient(180deg, rgba(25, 167, 181, 1) 0%, rgba(2, 48, 60, 1) 53.09%, rgba(25, 167, 181, 1) 100%) !important;
      border-color: rgba(20, 109, 142, 1) !important;
    }
  }
}

// el-input 样式覆盖 - 说明：它的宽度取决于它父容器的宽度！
:deep(.el-input) {
  width: 100% !important;
  height: px2vw(32) !important;
  
  // 输入组样式
  &.el-input-group {
    border: px2vw(1) solid rgba(175, 215, 230, 0.5) !important;
    border-radius: px2vw(2) !important;
    background-color: transparent !important;
    display: flex !important;
    
    .el-input__wrapper {
      height: px2vw(32) !important;
      border: none !important;
      border-radius: 0 !important;
      background-color: transparent !important;
      box-shadow: none !important;
      
      // 输入框内文字
      .el-input__inner {
        height: px2vw(30) !important;
        line-height: px2vw(30) !important;
        color: rgba(255, 255, 255, 1) !important;
        background-color: transparent !important;
        font-size: px2vw(14) !important;
      }
    }
    
    // 后缀内容样式
    .el-input-group__append {
      height: px2vw(30) !important;
      line-height: px2vw(30) !important;
      background-color: transparent !important;
      border: none !important;
      border-left: px2vw(1) solid rgba(175, 215, 230, 0.5) !important;
      color: rgba(0, 255, 244, 1) !important;
      padding: 0 px2vw(10) !important;
      border-radius: 0 !important;
      font-size: px2vw(14) !important;
      box-shadow: none !important;
    }
  }
}

// el-input 通用样式 - 适用于普通输入框（非 input-group）
:deep(.el-input) {
  width: 100% !important;
  
  &:not(.el-input-group) {
    .el-input__wrapper {
      height: px2vw(32) !important;
      border-radius: px2vw(2) !important;
      border: px2vw(1) solid rgba(175, 215, 230, 0.5) !important;
      background-color: transparent !important;
      box-shadow: none !important;
      padding: 0 !important; // 去掉内边距
      
      // 输入框内文字
      .el-input__inner {
        height: px2vw(30) !important;
        line-height: px2vw(30) !important;
        color: rgba(255, 255, 255, 1) !important;
        background-color: transparent !important;
        font-size: px2vw(14) !important;
        padding: 0 px2vw(12) !important; // 保留输入框内文字的左右内边距
        
        // placeholder 样式
        &::placeholder {
          color: rgba(175, 215, 230, 0.5) !important;
        }
      }
      
      // 清除按钮
      .el-input__suffix {
        .el-input__suffix-inner {
          .el-input__clear {
            position: relative !important;
            width: px2vw(14) !important;
            height: px2vw(14) !important;
            margin-right: px2vw(12) !important; // 距离右边的距离
            
            // 隐藏默认的 SVG 图标
            svg {
              display: none !important;
            }
            
            // 使用自定义图标背景
            &::before {
              content: '';
              position: absolute;
              top: 0;
              left: 0;
              width: px2vw(14);
              height: px2vw(14);
              background: url('@/assets/icons/icon_input_clear.png') no-repeat center;
              background-size: contain;
              opacity: 0.8;
              transition: opacity 0.3s;
              cursor: pointer;
            }
            
            &:hover::before {
              opacity: 1;
            }
          }
        }
      }
      
      // hover 状态
      &:hover {
        border-color: rgba(0, 255, 244, 0.5) !important;
      }
    }
    
    // 聚焦状态
    &.is-focus {
      .el-input__wrapper {
        border-color: rgba(0, 255, 244, 0.8) !important;
      }
    }
  }
}

// el-input 搜索框样式 - 用于任务执行弹窗
:deep(.task-search-input) {
  width: 100% !important;
  height: px2vw(32) !important;
  
  .el-input__wrapper {
    height: px2vw(32) !important;
    border-radius: px2vw(2) !important;
    border: px2vw(1) solid rgba(175, 215, 230, 0.5) !important;
    background-color: transparent !important;
    box-shadow: none !important;
    
    // 输入框内文字
    .el-input__inner {
      height: px2vw(30) !important;
      line-height: px2vw(30) !important;
      color: rgba(255, 255, 255, 1) !important;
      background-color: transparent !important;
      font-size: px2vw(14) !important;
      
      // placeholder 样式
      &::placeholder {
        color: rgba(175, 215, 230, 1) !important;
      }
    }
    
    // 搜索图标
    .el-input__suffix {
      .el-icon {
        color: rgba(175, 215, 230, 1) !important;
        font-size: px2vw(16) !important;
      }
    }
  }
}

// 通用表格样式 - 可复用于多个页面
:deep(.common-table) {
  width: 100% !important;
  background: transparent !important;
  
  // 表头样式
  .el-table__header-wrapper {
    .el-table__header {
      tr {
        background: linear-gradient(90deg, rgba(5, 140, 187, 0.28) 0%, rgba(5, 173, 187, 0.08) 100%) !important;
        height: px2vw(31) !important;
      }
      
      th {
        background: transparent !important;
        height: px2vw(31) !important;
        padding: 0 !important;
        border-bottom: none !important;
        
        .cell {
          white-space: nowrap;
          padding: 0 px2vw(10) !important;
          height: px2vw(31) !important;
          line-height: px2vw(31) !important;
          font-size: px2vw(16) !important;
          color: rgba(175, 215, 230, 1) !important;
          font-weight: 500 !important;
        }
      }
    }
  }
  
  // 表体样式
  .el-table__body-wrapper {
    .el-table__body {
      border-spacing: 0 px2vw(4) !important;
      
      tr {
        min-height: px2vw(39) !important;
        
        &.odd-row {
          background: linear-gradient(90deg, rgba(5, 140, 187, 0.25) 0%, rgba(5, 173, 187, 0.07) 100%) !important;
        }
        
        &.even-row {
          background: linear-gradient(90deg, rgba(5, 140, 187, 0.11) 0%, rgba(5, 173, 187, 0.03) 100%) !important;
        }
        
        // 选中行样式
        &.selected-row {
          box-shadow: inset 0px 0px px2vw(6) px2vw(1) rgba(0, 255, 244, 0.7) !important;
          position: relative;
        }
        
        // hover 样式
        &:hover {
          td {
            background-color: rgba(0, 255, 244, 0.05) !important;
          }
          
          &:not(.selected-row) {
            box-shadow: inset 0px 0px px2vw(4) 0 rgba(0, 255, 244, 0.3) !important;
            cursor: pointer;
          }
        }
        
        td {
          border: none !important;
          background: transparent !important;
          color: #FFFFFF !important;
          height: px2vw(39) !important;
          min-height: px2vw(39) !important;
          padding: 0 !important;
          
          .cell {
            padding: 0 px2vw(10) !important;
            font-size: px2vw(14) !important;
            line-height: px2vw(39) !important;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
          }
        }
      }
    }
  }
  
  // 滚动条样式
  .el-table__body-wrapper {
    &::-webkit-scrollbar {
      width: px2vw(6);
      height: px2vw(6);
    }
    
    &::-webkit-scrollbar-track {
      background: rgba(0, 0, 0, 0.1);
      border-radius: px2vw(3);
    }
    
    &::-webkit-scrollbar-thumb {
      background: rgba(0, 255, 244, 0.3);
      border-radius: px2vw(3);
      
      &:hover {
        background: rgba(0, 255, 244, 0.5);
      }
    }
  }
  
  // 去除表格边框
  &::before {
    display: none;
  }
  
  .el-table__inner-wrapper::before {
    display: none;
  }
}

// el-select 样式覆盖 - 注意：这是覆盖 node_modules 的样式，所以需要使用 px2vw
:deep(.el-select) {
  width: 100% !important;
  
  // 重要：设置整体高度
  &,
  & > .el-select__wrapper {
    height: px2vw(32) !important;
  }
  
  .el-select__wrapper {
    min-height: px2vw(32) !important;
    border-radius: px2vw(2) !important;
    border: px2vw(1) solid rgba(175, 215, 230, 0.5) !important;
    background-color: transparent !important;
    box-shadow: none !important;
    padding: 0 px2vw(12) !important; // 添加左右内边距
    
    // 选择框内容
    .el-select__selection {
      height: px2vw(30) !important;
      display: flex !important;
      align-items: center !important;
      
      // 通用样式
      .el-select__selected-item {
        font-size: px2vw(14) !important;
        line-height: px2vw(30) !important;
      }
      
      // placeholder - 当有 is-transparent 类时
      .el-select__selected-item.el-select__placeholder.is-transparent {
        color: rgba(175, 215, 230, 0.5) !important;
        
        span {
          color: rgba(175, 215, 230, 0.5) !important;
        }
      }
      
      // 选中的值 - 没有 is-transparent 类时
      .el-select__selected-item.el-select__placeholder:not(.is-transparent) {
        color: rgba(255, 255, 255, 1) !important;
        
        span {
          color: rgba(255, 255, 255, 1) !important;
        }
      }
    }
    
    // 下拉箭头图标
    .el-select__suffix {
      .el-select__caret {
        // 隐藏默认图标
        display: none !important;
      }
      
      // 使用自定义图标
      &::after {
        content: '';
        display: block;
        width: px2vw(14);
        height: px2vw(14);
        background: url('@/assets/icons/icon_fold_up_panel2.png') no-repeat center;
        background-size: contain;
        transform: rotate(180deg); // 默认向下
        transition: transform 0.3s;
      }
    }
    
    // hover 状态
    &:hover {
      border-color: rgba(0, 255, 244, 0.5) !important;
    }
  }
  
  // 聚焦状态
  &.is-focus {
    .el-select__wrapper {
      border-color: rgba(0, 255, 244, 0.8) !important;
    }
    
    // 展开时旋转图标
    .el-select__suffix::after {
      transform: rotate(0deg);
    }
  }
  
  // 禁用状态
  &.is-disabled {
    .el-input__inner {
      color: rgba(255, 255, 255, 0.5) !important;
    }
  }
}

// el-select 下拉菜单样式
:deep(.el-select-dropdown) {
  background: rgba(2, 24, 34, 0.95) !important;
  border: px2vw(1) solid rgba(0, 255, 244, 0.3) !important;
  border-radius: px2vw(4) !important;
  
  .el-select-dropdown__wrap {
    max-height: px2vw(200) !important;
  }
  
  .el-select-dropdown__list {
    padding: px2vw(4) 0 !important;
    
    .el-select-dropdown__item {
      height: px2vw(32) !important;
      line-height: px2vw(32) !important;
      padding: 0 px2vw(14) !important;
      font-size: px2vw(14) !important;
      color: rgba(255, 255, 255, 0.8) !important;
      background: transparent !important;
      
      &:hover {
        background: rgba(0, 255, 244, 0.1) !important;
        color: rgba(0, 255, 244, 1) !important;
      }
      
      &.is-selected {
        background: rgba(0, 255, 244, 0.2) !important;
        color: rgba(0, 255, 244, 1) !important;
        font-weight: 500 !important;
      }
    }
  }
  
  // 滚动条样式
  .el-scrollbar__bar {
    width: px2vw(6) !important;
    
    .el-scrollbar__thumb {
      background: rgba(0, 255, 244, 0.3) !important;
      border-radius: px2vw(3) !important;
      
      &:hover {
        background: rgba(0, 255, 244, 0.5) !important;
      }
    }
  }
}

// el-slider 样式覆盖
:deep(.el-slider) {
  height: px2vw(10) !important; // 设置整体高度
  
  // 轨道样式
  .el-slider__runway {
    height: px2vw(10) !important;
    background: rgba(106, 147, 159, 1) !important;
    border-radius: px2vw(2) !important; // 修改圆角为2px
    
    // 进度条样式
    .el-slider__bar {
      height: px2vw(10) !important;
      background: rgba(0, 255, 244, 1) !important;
      border-radius: px2vw(2) !important; // 修改圆角为2px
    }
    
    // 滑块按钮样式
    .el-slider__button-wrapper {
      width: px2vw(16) !important;
      height: px2vw(16) !important;
      top: 50% !important;
      transform: translate(-50%, -50%) !important; // 水平垂直居中
      
      .el-slider__button {
        display: block !important;
        width: px2vw(16) !important;
        height: px2vw(16) !important;
        border: none !important;
        border-radius: px2vw(2) !important;
        background: rgba(255, 255, 255, 1) !important;
        position: relative;
        box-shadow: none !important;
        outline: none !important;
        
        // 添加两条竖线伪元素
        &::before,
        &::after {
          content: '';
          position: absolute;
          width: px2vw(2) !important;
          height: px2vw(6) !important;
          background: rgba(106, 147, 159, 1) !important;
          border-radius: px2vw(1) !important;
          top: 50% !important;
          transform: translateY(-50%) !important;
          transition: none !important; // 防止hover时的动画
          pointer-events: none !important; // 防止鼠标事件干扰
        }
        
        &::before {
          left: px2vw(4) !important; // 左边竖线
        }
        
        &::after {
          right: px2vw(4) !important; // 右边竖线
        }
        
        // 各种状态下都保持伪元素稳定
        &:hover,
        &:focus,
        &:active,
        &.hover,
        &.focusing {
          &::before,
          &::after {
            content: '';
            position: absolute;
            width: px2vw(2) !important;
            height: px2vw(6) !important;
            background: rgba(106, 147, 159, 1) !important;
            border-radius: px2vw(1) !important;
            top: 50% !important;
            transform: translateY(-50%) !important;
            left: auto !important;
            right: auto !important;
          }
          
          &::before {
            left: px2vw(4) !important;
          }
          
          &::after {
            right: px2vw(4) !important;
          }
        }
      }
    }
  }
}

// 自定义搜索输入框样式 - 用于新建任务页面的搜索设备组件
:deep(.custom-search-input) {
  width: 100% !important;
  
  .el-input__wrapper {
    height: px2vw(32) !important;
    border-radius: px2vw(2) !important;
    border: px2vw(1) solid rgba(175, 215, 230, 0.5) !important;
    background-color: transparent !important;
    box-shadow: none !important;
    
    // 输入框内文字
    .el-input__inner {
      height: px2vw(30) !important;
      line-height: px2vw(30) !important;
      color: rgba(255, 255, 255, 1) !important;
      background-color: transparent !important;
      font-size: px2vw(14) !important;
      padding: 0 px2vw(12) !important;
      
      // placeholder 样式
      &::placeholder {
        color: rgba(175, 215, 230, 0.5) !important;
      }
    }
    
    // 自定义搜索图标
    .el-input__suffix {
      .el-input__suffix-inner {
        .custom-search-icon {
          display: inline-block;
          width: px2vw(12);
          height: px2vw(13);
          margin-right: px2vw(11);
          background: url('@/assets/icons/icon_search.png') no-repeat center;
          background-size: contain;
          cursor: pointer;
        }
      }
    }
    
    // hover 状态
    &:hover {
      border-color: rgba(0, 255, 244, 0.5) !important;
    }
  }
  
  // 聚焦状态
  &.is-focus {
    .el-input__wrapper {
      border-color: rgba(0, 255, 244, 0.8) !important;
    }
  }
}